<template>
	<!-- 员工管理 -->
	<view>
		<view class="toptext">
			<text class="text">{{title}}</text>
		</view>
		<view class="topinput">
			<input type="text" placeholder="搜索" v-model="filterText">
			<select v-model="selectdata">
				<option value=''>成员名称</option>
				<option>性别</option>
				<option>账号</option>
			</select>
		</view>
		<view class="boxhead" v-for="(item,index) in filterList" :key="index" @click="navto(index)">
			<view class="news_item">
				<view class="top">
					<image class="img1" :src="item.headimg"></image>
				</view>
				<view class="right">
					<view class="tit">
						<text class="text">成员名称:</text>
						<text class="text1">{{item.empname}}</text>
					</view>
					<hr>
					<view class="info">
						<text class="text">所属部门编号:</text>
						<text class="text1">{{item.departmentid}}</text>
					</view>
				</view>
			</view>	
		</view>
		<view>
			<drag-button  name="新增" :isDock="true" :existTabBar="true" @btnClick="btnClick" />
		</view>
	</view>
</template>

<script>
	import dragButton from '../../../components/drag-button.vue';
	export default {
		components: {
			dragButton
		},
		data() {
			return {
				title:'员工管理',data:'',filterText:'',selectdata:'',
				list:[]
			}
		},
		onLoad() {
			this.getdata();
		},
		computed:{
			filterList() {
				let selectdata = this.selectdata;
				var arr = []
				this.list.forEach((item) => arr.push(item))	
				if (this.filterText) {
					if(selectdata==''){
						arr = this.list.filter(item => item.empname.includes(this.filterText))
					}else if(selectdata=='性别'){
						arr = this.list.filter(item => item.sex.includes(this.filterText))
					}else if(selectdata=='账号'){
						arr = this.list.filter(item => item.account.includes(this.filterText))
					}	
				}
				return arr
			}			
		},
		methods: {
			async getdata(){
				const res =await this.Request({
					url:'/api/employee/getper'
				})
				this.list = res.data
				this.data = res
			},
			navto(e){
				var item = JSON.stringify(this.data.data[e]);
				uni.navigateTo({
					url:'/pages/super/superpage/emppage?item=' + item
				})
			},
			btnClick(){
				setTimeout(() => {
					uni.navigateTo({
						url:'/pages/super/superpage/empadd'
					})
				},300)
			}
		}
	}
</script>

<style lang="scss">
	.toptext{
		width: 100%;
		background-color: #efefef;
		display: flex;
		border-bottom: 1px solid #ccc;
		.text{
			margin: 5px 0 5px 5px;
			font-size: 110%;
			font-weight: 700;
			color: #d3d3d3;
		}
	}
	.topinput{
		display: flex;
		input{
			height: 30px;
			width: 200px;
			margin: 15px 0 15px 20px;
			border-radius: 10px;
			border: 2px solid #919191;
		}
		select{
			margin: 15px 0 15px 30px;
			border-radius: 10px;
		}
	}
	.boxhead{
		.news_item{
			height: 90px;
			width: 100%;
			border: 2px solid #ccc;
			display: flex;
			.top{
				display: flex;
				width: 120px;
				.img1{
					margin: auto;
					margin: 10px 0 10px 30px;
					width: 70px;
					height: 70px;
					border-radius: 10px;
				}
			}
			.right{
				width: 180px;
				border-left: 2px solid #ccc;
				margin-left: 20px;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.tit{
					margin-left:15px;					
					margin-top: 12px;
					.text{
						font-size: 16px;
						font-weight: 700;
					}
					.text1{
						margin-left: 10px;
						font-size: 18px;
						color: #ff00ff;
					}
				}
				.info{
					font-size: 13px;
					margin-left:15px;
					margin-bottom: 10px;
					.text{
						font-size: 16px;
						font-weight: 700;
					}
					.text1{
						margin-left: 10px;
						font-size: 18px;
						color: #ff00ff;
					}
				}
			}
		}
	}
	.boxhead :active{
		background-color: #bcbcbc;
	}
</style>
